home *** CD-ROM | disk | FTP | other *** search
/ Professional Soft Collection 1.02 / Professional Soft Collection 1.02.iso / bonusrus.os2 / sysinfo / sysi.cmd < prev    next >
OS/2 REXX Batch file  |  1995-05-16  |  6KB  |  257 lines

  1. /* **********************************************************************
  2. *  *               Copyright (c) IBM Corporation, 1994                  *
  3. *  *                       All Rights Reserved                          *
  4. *  **********************************************************************
  5. *
  6. *                IBM System Information Tool Installation
  7. */
  8.  
  9.    '@echo off'
  10.    trace off
  11.  
  12.    /* Load in function library
  13.    */
  14.    Call RxFuncAdd "SysLoadFuncs","RexxUtil","SysLoadFuncs"
  15.    Call SysLoadFuncs
  16.  
  17.    /* Parse Call Path Info
  18.    */
  19.    Parse Source . . callPath
  20.  
  21.    /* Strip program name
  22.    */
  23.    rcp = REVERSE(callPath)
  24.    callPathDir = REVERSE(substr(rcp,POS("\",rcp)+1))
  25.  
  26.    /* Create Queue to catch system error messages
  27.    */
  28.    rcode = RXQUEUE('delete', errq)
  29.    errq = RXQUEUE('create')
  30.    new = RXQUEUE('set', errq)
  31.  
  32.    /* Define stem of files to be copied
  33.    */
  34.    MaxCopyIndex = 2
  35.    Files. = ""
  36.    Files.0 = MaxCopyIndex
  37.    Files.1 = "SYSINFO.@"
  38.    Files.2 = "RSPDDI.EXE"
  39.  
  40.    /* Determine bootdrive
  41.    */
  42.    CurDir = DIRECTORY()
  43.    SrcDir = callPathDir
  44.    if (SubStr(SrcDir,Length(SrcDir),1) \= "\") then
  45.      SrcDir = SrcDir||"\"
  46.    PathStr = VALUE("PATH",,"OS2ENVIRONMENT")
  47.    InsPathPos = POS("\OS2\INSTALL",PathStr)
  48.    if (InsPathPos == 0) then
  49.      InsPathPos = POS("\os2\install",PathStr)
  50.    if (InsPathPos \= 0) then
  51.      do
  52.        BootDrive = Substr(PathStr,InsPathPos-2,2)
  53.        InsPath = TRANSLATE(BootDrive||"\OS2\INSTALL")
  54.      end
  55.    else do
  56.          /* \OS2\INSTALL is a required path directory!
  57.          */
  58.          'helpmsg SYS0010 | RXQUEUE 'errq
  59.           call DumpErrMsg
  60.           call Done
  61.         end
  62.  
  63.    /* Verify Source Files
  64.    */
  65.    do i = 1 to MaxCopyIndex
  66.      rc = VerifySourcePath( SrcDir||Files.i )
  67.      if ( rc == 1 ) then
  68.        call Done
  69.    end
  70.  
  71.    /* Check and Clean Dirty System
  72.    */
  73.    InsDir = DIRECTORY(InsPath)
  74.    if (InsDir == InsPath) then
  75.      do
  76.        CleanDir = InsDir||"\SYSINFO"
  77.        TargetDir = DIRECTORY(CleanDir)
  78.        if (TargetDir == CleanDir) then
  79.          do
  80.            call DeleteFiles CleanDir
  81.            InsDir = DIRECTORY(InsPath)
  82.            rc = SysRmDir(CleanDir)
  83.            if (rc \= 0) then
  84.              do
  85.                'helpmsg sys'||rc||' | RXQUEUE 'errq
  86.                call DumpErrMsg
  87.                call Done
  88.              end
  89.          end
  90.      end
  91.     else do
  92.            /* \OS2\INSTALL is a required path directory!
  93.            */
  94.            'helpmsg SYS0010 | RXQUEUE 'errq
  95.             call DumpErrMsg
  96.             call Done
  97.          end
  98.  
  99.    /* Unpack files and run RSPDDI
  100.    */
  101.    tmpDir = DIRECTORY(InsPath)
  102.    if (tmpDir \= "") then
  103.      do
  104.        rc = SysMkDir("SysInfo")
  105.        if (rc \= 0) then
  106.          do
  107.            'helpmsg sys'||rc||' | RXQUEUE 'errq
  108.            call DumpErrMsg
  109.            call Done
  110.          end
  111.        NewDir = InsDir||"\SYSINFO"
  112.        tmpDir = DIRECTORY(NewDir)
  113.        success = UnpackFiles(SrcDir, tmpDir, 1)
  114.        if (success == 0) then
  115.          do
  116.            /* Run RSPDDI from \OS2\INSTALL or Source Drive
  117.            */
  118.            rc = VerifySourcePath( InsPath||"\"||Files.2 )
  119.            if ( rc == 1 ) then
  120.              SrcDir||Files.2 tmpDir
  121.            else InsPath||"\"||Files.2 tmpDir
  122.            call DeleteFiles tmpDir
  123.            tempDir = DIRECTORY(InsPath)
  124.            rc = SysRmDir(NewDir)
  125.            if (rc \= 0) then
  126.              do
  127.                'helpmsg sys'||rc||' | RXQUEUE 'errq
  128.                call DumpErrMsg
  129.                call Done
  130.              end
  131.            tmpDir = DIRECTORY(SrcDir)
  132.            call UpdateWPShell BootDrive
  133.            'helpmsg SYS1716 | RXQUEUE 'errq
  134.             call DumpErrMsg
  135.          end
  136.      end
  137.  
  138. Done:
  139.    rc = RXQUEUE('delete', errq)
  140.    exit
  141.  
  142. /* Procedures and Functions
  143. */
  144.  
  145. VerifySourcePath: Procedure Expose errq
  146.  
  147.    Parse Arg file;
  148.  
  149.    fExists = Stream(file,'c','query exists')
  150.    if (fExists == "")
  151.      then do
  152.            'helpmsg SYS002 | RXQUEUE 'errq
  153.             call DumpErrMsg
  154.             return 1
  155.           end
  156.  
  157. return 0
  158.  
  159. UnpackFiles: Procedure Expose Files. errq
  160.  
  161.    Parse Arg SrcPath, TargetPath, index;
  162.  
  163.    if (SubStr(SrcPath,Length(SrcPath),1) == "\") then
  164.      unpackstr = SrcPath||Files.index||" "||TargetPath||,
  165.                  " /V /F  > nul 2>&1"
  166.    else unpackstr = SrcPath||"\"||Files.index||" "||TargetPath||,
  167.                     " /V /F > nul 2>&1"
  168.  
  169.    'unpack 'unpackstr
  170.  
  171.    if (rc \= 0) then
  172.      do
  173.        'helpmsg sys'||rc||' | RXQUEUE 'errq
  174.        call DumpErrMsg
  175.        return 1
  176.      end
  177.  
  178. return 0
  179.  
  180. DumpErrMsg: Procedure
  181.  
  182.    do while(QUEUED() \= 0)
  183.      parse pull line
  184.      if (POS("SYS",line) \= 0) then
  185.        fFound = 1
  186.      if ((line == "") & (fFound = 1)) then
  187.        do
  188.          /* Empty out queue
  189.          */
  190.          do while(QUEUED() \= 0)
  191.            parse pull line
  192.          end
  193.          leave
  194.        end
  195.      if (POS("SYS1716:",line) \= 0) then
  196.        say SubStr(line,POS(":",line)+2)
  197.      else say line
  198.    end
  199.  
  200. return
  201.  
  202. DeleteFiles: Procedure Expose errq
  203.  
  204.    Parse Arg dir;
  205.  
  206.    fspec = dir||"\*.*"
  207.    call SysFileTree fspec, 'dellst', 'FO'
  208.    do i = 1 to dellst.0
  209.      rc = SysFileDelete(dellst.i)
  210.      if (rc \= 0) then
  211.        do
  212.          'helpmsg sys'||rc||' | RXQUEUE 'errq
  213.          call DumpErrMsg
  214.        end
  215.    end
  216.  
  217. return
  218.  
  219. UpdateWPShell: Procedure
  220.  
  221.    Parse Arg drv;
  222.  
  223.    /* Create Program Object in the "System Setup" Folder
  224.    */
  225.    pgmpath   = drv||'\OS2\APPS\SYSIGUI.EXE'
  226.    classname = 'WPProgram'
  227.    title     = 'System Information Tool'
  228.    location  = '<WP_CONFIG>'
  229.    setup     = 'OBJECTID=<SysInfo>;'||,
  230.                'EXENAME='||pgmpath||';'||,
  231.                'PROGTYPE=PM;'
  232.  
  233.    rc = SysCreateObject(classname, title, location, setup, 'f')
  234.  
  235.    /* Open "System Setup" Folder
  236.    */
  237.    object    = '<WP_CONFIG>'
  238.    setup     = 'OPEN=DEFAULT'
  239.  
  240.    rc = SysSetObjectData(object, setup)
  241.  
  242.    /* Create a shadow of "System Setup" Folder icon on the Desktop.
  243.    *  93447: This approach was removed in favor of openning the
  244.    *  "System Setup" Folder.
  245.    */
  246.    /*
  247.    classname = 'WPShadow'
  248.    title     = 'System Information Tool'
  249.    location  = '<WP_DESKTOP>'
  250.    setup     = 'SHADOWID=<SysInfo>'
  251.  
  252.    rc = SysCreateObject(classname, title, location, setup, 'f')
  253.    */
  254.  
  255. return
  256.  
  257.